<extend name="Public:template" />
<block name="page_header">
	<include file="Public:header_cust"/>
</block>
<block name="page_body">
	<div class="row">
		<div class="span4">
			<include file="Public:left_menu_cust"/>
		</div>
		<div class="span16">
			<include file="Public:breadcrumb_cust"/>
		</div>
		<div class="span8">
			<table class="table table-bordered">
				<tr>
					<th class="alert-warning text-left" style="font-size:14px"><img class="img-thumbnail" src="__ROOT__/statics/mobile/images/icons/user_green.png"><span>&nbsp;完善个人信息</span></th>
				</tr>
				<tr>
					<td>
					<div id="alert_box">
						<div class="alert alert-success" style="display:none"></div>
						<div class="alert alert-danger" style="display:none"></div>
					</div>
					<form action="{:U('CustPassport/doUpd')}" method="post" id="form_edit" name="form_edit" role="form">
						<input type="hidden" name="sex" value="{$cust.sex}">
						<div class="input-prepend">
							<span class="btn ">姓名或昵称</span>
							<input type="text" class="input-xlarge"  id="name" name="name"  value="{$cust.name}" placeholder="请输入要修改的姓名或昵称">
						</div>
						<div class="input-prepend input-append pull-left">
							<span class="btn" id="man" onclick="updSex('先生')" >先生</span>
		 	 				<span class="btn" id="woman" onclick="updSex('女士')">女士</span>
						</div>
					</form>
					</td>
				</tr>
				<tr>
					<td>						
						<button type="button" id="doUpdBtn" class="btn btn-warning active mt15"><span class="icon-white icon-pencil"></span>提交修改</button>
					</td>
				</tr>
			</table>
		</div>
		<div class="span8">
			<div class="alert alert-success">
			姓名和昵称：配送过程中，可能会通过该名称联系您。<br>
			最近的店铺：为了您能更快的收到商品，请选择离您家或公司最近的店铺（配送地点）。
				
			</div>
			<div id="addressDesc" class="alert alert-danger" style="display:none;"></div>
		</div>
</block>
<block name="script_footer">
<script type="text/javascript">
$(document).ready(function(){
	updSex('{$cust.sex}');		
	$("#doUpdBtn").on( "click", function() {
		$("#alert_box .alert-danger").hide();
		$("#alert_box .alert-success").hide();
		$.ajax({
	        'url': $("#form_edit").attr("action"),
	        'type':"post",
	        'dataType': "json",
	        'data': $('#form_edit').serialize(),
	        'success': function (data) {
	        	var error = data['error'];
	        	var message = data['message'];
	        	if(error=='0'){
	        		$("#alert_box .alert-success").html(message).show;
	        		alert(message);
	        		document.location.href="/Cust/index.html"; 
	        	}else{
	        		$("#alert_box .alert-danger").html(message).show();
	        	}
	        }
	    });
	});
})
function updSex(sex){
	if('女士' == sex){
		$("#man").removeClass("btn-info active").addClass("btn-default");
		$("#woman").removeClass("btn-default").addClass("btn-danger active");
		document.forms['form_edit'].sex.value="女士";
	}else{
		$("#man").removeClass("btn-default").addClass("btn-info active");
		$("#woman").removeClass("btn-danger active").addClass("btn-default");
		document.forms['form_edit'].sex.value="先生";
	}
}
function changeShop(){
	var shop_id = $("#shop_id").val();
	if(shop_id!=''){
		$("#addressDesc").html("当前选择的店铺配送范围："+$("#deliver"+shop_id).attr("deliver_around"));
		$("#addressDesc").show();
	}else{
		$("#addressDesc").html("如果配送地址没有覆盖您的区域，请联系我们的客服");
		$("#addressDesc").show();
	}

}
</script>
</block>